using System;
using System.Collections;
using FakeGameEngine;

public class Character : GameObject
{
    public string Name { get; private set; }

    public Character(string name) : base()
    {
        Name = name;
    }

    IEnumerator Anounce()
    {
        yield return null;
        Console.WriteLine("I");
        yield return null;
        Console.WriteLine("AM");
        yield return null;
        Console.WriteLine(this.Name);
        yield return null;
        yield return null;
        Console.WriteLine("!!!");
    }

    public override void Awake()
    {
        Console.WriteLine("[Character Awake]");
        StartCoroutine(Anounce());
    }

    public override void Update()
    {
        Console.WriteLine("[Character Update]");
    }
}

public class Monster : GameObject
{
    private Coroutine _coroutine;

    public override void Update()
    {
        Console.WriteLine("[Monster Update]");
        if (Time.FrameCount == 1)
        {
            _coroutine = StartCoroutine(Laugh(10));
        }
        else if (Time.FrameCount == 6)
        {
            StopCoroutine(_coroutine);
        }
    }

    IEnumerator Laugh(int count)
    {
        int i = 0;
        string laugh = "h";
        while (i++ < count)
        {
            laugh += "ah";
            Console.WriteLine(laugh);
            yield return null;
        }
    }
}

public class Program
{
    public static void Main()
    {
        GameEngine.Instance.Init(new Character("Iron Man"), new Monster());
        GameEngine.Instance.Run();
    }
}